<template>
  <div>
    <li v-for="(val, index) in arr" :key="index">
      {{ val }}<button @click="btn1(index)">删除</button>
    </li>
    <button @click="btn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [2, 6, 3, 5],
    };
  },
  methods: {
    btn() {
      this.arr.push(Math.floor(Math.random() * 20));
    },
    btn1(index) {
      this.arr.splice(index, 1); //  1删除1个
    },
  },
};
</script>

<style>
</style>